/**
 * Created by Administrator on 2017/3/2 0002.
 */
var Page3={
    create:function () {
        var page={};

        var tw_t0,tw_t1,tw_t2,tw_t22,tw_t3,tw_t4,tw_line1,tw_line2,tw_gp0,tw_gp1;
        page.ui=new PIXI.DisplayObjectContainer();

        var bg=new PIXI.Sprite(resource['assets/images/p1_bg.png'].texture);
        page.ui.addChild(bg);

        var gp=new PIXI.Graphics();
        gp.beginFill(0x0);
        gp.drawRect(0,0,461,549);
        gp.x=138;
        gp.y=465;
        gp.scale.x=1;
        gp.scale.y=1;
        gp.alpha=0;
        page.ui.addChild(gp);
        // TweenMax.to(gp,1.5,{alpha:0.6,ease:Cubic.easeInOut,yoyo:true,repeat:-1});

        var t0=new PIXI.Sprite(resource['assets/images/p3_t0.png'].texture);
        t0.x=370;
        t0.y=144;
        t0.alpha=0;
        t0.anchor.set(0.5);
        page.ui.addChild(t0);
        // console.log(t0.texture.width);

        var t1=new PIXI.Sprite(resource['assets/images/p3_t1.png'].texture);
        t1.x=370;
        t1.y=561;
        t1.alpha=0;
        t1.anchor.set(0.5);
        page.ui.addChild(t1);

        var t2=new PIXI.Sprite(resource['assets/images/p3_t2.png'].texture);
        t2.x=370;
        t2.y=700;
        t2.alpha=0;
        t2.anchor.set(0.5);
        page.ui.addChild(t2);

        var t22=new PIXI.Sprite(resource['assets/images/p0_t1.png'].texture);
        t22.x=370;
        t22.y=775;
        t22.alpha=0;
        t22.anchor.set(0.5);
        page.ui.addChild(t22);

        var t3=new PIXI.Sprite(resource['assets/images/p3_t3.png'].texture);
        t3.x=370;
        t3.y=891;
        t3.alpha=0;
        t3.anchor.set(0.5);
        page.ui.addChild(t3);

        var t4=new PIXI.Sprite(resource['assets/images/p3_t4.png'].texture);
        t4.x=370;
        t4.y=1017;
        t4.scale.x=t4.scale.y=0;
        t4.alpha=1;
        t4.anchor.set(0.5);
        page.ui.addChild(t4);
        
        // t4.interactive=true;
        // t4.on('pointerdown',downHandler);
        // t4.on('pointerup',upHandler);

        var tip= new PIXI.Sprite(resource['assets/images/tip.png'].texture);
        tip.x = 370;
        tip.y = 1105;
        tip.alpha = 1;
        tip.anchor.set(0.5);
        // page.ui.addChild(tip);
        TweenMax.to(tip,0.7,{y:1105-30,ease:Cubic.easeInOut,yoyo:true,repeat:-1});

        var line1=new PIXI.Graphics();
        line1.beginFill(0xffffff);
        line1.drawRect(-150/2,0,150,1);
        line1.x=368;
        line1.y=643;
        line1.scale.x=0;
        line1.scale.y=1;
        line1.alpha=1;
        page.ui.addChild(line1);

        var line2=new PIXI.Graphics();
        line2.beginFill(0xffffff);
        line2.drawRect(-150/2,0,150,1);
        line2.x=368;
        line2.y=819;
        line2.scale.x=0;
        line2.scale.y=1;
        line2.alpha=1;
        page.ui.addChild(line2);


        var logo=new PIXI.Sprite(resource['assets/images/tip1.png'].texture);
        logo.x=712;
        logo.y=967;
        logo.alpha=0;
        logo.scale.x=logo.scale.y=1.2;
        logo.anchor.set(0.5);
        page.ui.addChild(logo);

        // var arr_texture=[];
        // for(var i=1;i<25;i++)
        // {
        //     if(i<10)
        //     {
        //         var texture = resource['assets/images/click000'+i.toString()+'.png'].texture;
        //     }
        //     else
        //     {
        //         var texture = resource['assets/images/click00'+i.toString()+'.png'].texture;
        //     }
        //     arr_texture.push(texture);
        //
        // }
        // var sp_click=new PIXI.extras.AnimatedSprite(arr_texture);
        // sp_click.anchor.set(0.5);
        // sp_click.x=380;
        // sp_click.y=900;
        // sp_click.animationSpeed=0.4;
        // sp_click.alpha=0;
        // sp_click.gotoAndPlay(1);
        // // page.ui.addChild(sp_click);
        // tw_click=new TWEEN.Tween({alpha:0,scale:0})
        //     .to({alpha:1,scale:1},1000)
        //     .onUpdate(function () {
        //         sp_click.scale.x=this.scale;
        //         sp_click.scale.y=this.scale;
        //         sp_click.alpha=this.alpha;
        //     })
        //     .delay(300)
        //     .easing(TWEEN.Easing.Back.Out);

        // var pt={x:0,y:0};
        // function downHandler(e) {
        //     pt.x=e.data.global.x;
        //     pt.y=e.data.global.y;
        // }
        // function upHandler(e)
        // {
        //     if((pt.x==e.data.global.x) && (pt.y=e.data.global.y))
        //     {
        //         window.location.href='http://weixin.qq.com/r/WUgiOszEqJHXrYhZ9x1L';
        //     }
        // }


        page.In=function () {
            TweenMax.killTweensOf(t0);
            TweenMax.killTweensOf(t1);
            TweenMax.killTweensOf(t2);
            TweenMax.killTweensOf(t3);
            TweenMax.killTweensOf(t4);

            t0.y=144-60;
            t1.x=370-100;
            t2.x=370+100;
            t22.x=370+100;
            t3.x=370-100;

            line1.scale.x=0;
            line2.scale.x=0;

            tw_t0=TweenMax.to(t0,1,{delay:0.0,y:144,alpha:1,ease:Cubic.easeInOut});
            // gp.scale.x=gp.scale.y=0;
            gp.alpha=0;
            tw_gp0=TweenMax.to(gp,1,{delay:0.3,alpha:0.5,ease:Cubic.easeInOut});

            tw_t1=TweenMax.to(t1,1,{delay:0.8,x:370,alpha:1,ease:Cubic.easeInOut});
            tw_line1=TweenMax.to(line1.scale,1,{delay:1.2,x:1,y:1,ease:Cubic.easeInOut});
            tw_t2=TweenMax.to(t2,1,{delay:1.4,x:370,alpha:1,ease:Cubic.easeInOut});
            tw_t22=TweenMax.to(t22,1,{delay:1.4,x:370,alpha:1,ease:Cubic.easeInOut});
            tw_line2=TweenMax.to(line2.scale,1,{delay:1.6,x:1,y:1,ease:Cubic.easeInOut});
            tw_t3=TweenMax.to(t3,1,{delay:2.0,x:370,alpha:1,ease:Cubic.easeInOut});

            t4.scale.x=t4.scale.y=0;
            tw_t4=TweenMax.to(t4.scale,1,{delay:2.2,x:1,y:1,ease:Back.easeOut});

            logo.x=690+70;
            logo.alpha=0;
            TweenMax.to(logo,1,{delay:2.4,x:690,alpha:1,ease:Back.easeOut});
            // document.getElementById('qcode').style.opacity=0;
            // document.getElementById('qcode').style.left=(window.innerWidth-134)/2+'px';
            // document.getElementById('qcode').style.top=600+(window.innerHeight-134)/2+'px';
            // TweenMax.to(document.getElementById('qcode').style,1,{delay:2.2,opacity:1});


        }

        page.Out=function () {
            // document.getElementById('qcode').style.opacity=0;
            tw_whole=TweenMax.to(page.ui,0.6,{alpha:0,onComplete:function () {
                t0.alpha=0;
                t1.alpha=0;
                t2.alpha=0;
                t22.alpha=0;
                logo.alpha=0;
                t3.alpha=0;
                gp.alpha=0;
                line1.scale.x=0;
                line2.scale.x=0;
                t4.scale.x=t4.scale.y=0;
                page.ui.alpha=1;
                // document.getElementById('qcode').style.opacity=0;
            }})
        }

        return page;
    }
}